package com.gz.rabbitmq.work;

import com.gz.rabbitmq.utils.ConnectionUtil;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class Producer {

    public static void main(String[] args) throws IOException, TimeoutException {
        Connection connection = ConnectionUtil.getConnection("demo");

        Channel channel = connection.createChannel();

        //                            队列名称           是否持久化     是否独占链接     是否自动删除     其他参数
        channel.queueDeclare("work_demo", true, false, false, null);

        for (int i = 0; i < 30; i++) {
            channel.basicPublish("", "work_demo", null, new StringBuilder().append(i).append("=========work模式测试").toString().getBytes());
        }

        channel.close();
        connection.close();
    }
}
